<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>
    function formSaveMethod(divId,formId,url,hrefUrl){
        if(flag){
            flag=false;
            formSubmitInput(formId);
            $("#"+formId+" input,#"+formId+" select").removeAttr("disabled");
            $.ajax({
                type: "POST",
                data:$("#"+formId).serialize(),
                url: url,
                dataType: "json",
                success: function (data) {
                    if (data.code == "success") {
                        toastr.success(data.data);
                        loadDiv(divId,hrefUrl);
                    }
                    else if(data.code == "repeat"){
                        toastr.error(data.data);
                    }
                    else {
                        flag=true;
                        toastr.error(data.data);
                    }
                },
                error: function(data) {
                    toastr.error('网络连接错误,请检查网络');
                    flag=true;
                }
            });
        }
        return false;
    }
</script>
<div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
            <ul class="nav nav-tabs">
                <li>
                    <a href="#"  onclick="loadDiv('mainCenterDiv','${ctx}/operation/operationRoom/index')">手术间列表</a>
                </li>
                <li class="active">
                    <a href="#" onclick="loadDiv('mainCenterDiv','${ctx}/operation/operationRoom/form')">
                        <c:choose>
                            <c:when test="${operationRoom.id==''|| operationRoom.id==null}">
                                手术间添加
                            </c:when>
                            <c:otherwise>手术间修改</c:otherwise>
                        </c:choose>
                    </a>
                </li>
            </ul>
            <section class="panel panel-default">
                <div class="panel-body">
                    <div class="col-lg-12">
                        <form:form id="inputForm" data-parsley-validate="" modelAttribute="operationRoom" onsubmit="return formSaveLoad('mainCenterDiv','inputForm','${ctx}/operation/operationRoom/save','${ctx}/operation/operationRoom/index');" method="post" class="form-horizontal">
                            <form:hidden path="id"/>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">手术间号：</label>
                                    <div class="col-sm-4">
                                        <form:input  path="roomNo" htmlEscape="false" class="form-control" data-parsley-required="true"  maxlength="3" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">所属手术室：</label>
                                    <div class="col-sm-4">
                                        <sys:treeselect selectedParent="true" id="orgDeptId" name="deptId" value="${operationRoom.deptId}"  update="${not empty orgDept.id}" labelName="${operationRoom.deptName}" labelValue="${operationRoom.deptName}"
                                                        title="科室" url="/sys/orgDept/treeData" extId="${orgDept.id}" cssClass="form-control" isnull="true"/>

                                        <%--<form:select data-parsley-validate="true" path="deptId" class="form-control" data-parsley-required="true">--%>
                                            <%--<option value="" label=""/>--%>
                                            <%--<c:forEach items="${list}" var="orgDept">--%>
                                                <%--<c:choose>--%>
                                                    <%--<c:when test="${orgDept.id==operationRoom.deptId}">--%>
                                                        <%--<option value="${orgDept.id}"--%>
                                                                <%--selected="selected">${orgDept.deptName}</option>--%>
                                                    <%--</c:when>--%>
                                                    <%--<c:otherwise>--%>
                                                        <%--<option value="${orgDept.id}">${orgDept.deptName}</option>--%>
                                                    <%--</c:otherwise>--%>
                                                <%--</c:choose>--%>
                                            <%--</c:forEach>--%>
                                        <%--</form:select>--%>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">位置：</label>
                                    <div class="col-sm-4">
                                        <form:input  path="location" htmlEscape="false" class="form-control" data-parsley-required="true"  maxlength="200" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">状态：</label>
                                    <div class="col-sm-4">
                                        <form:select path="status" class="form-control" data-parsley-required="true">
                                            <form:option value="" label=""/>
                                            <form:options items="${fns:getDictList('USED_OR_NOT')}" itemLabel="label"
                                                          itemValue="value" htmlEscape="false"/>
                                        </form:select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">备注信息：</label>
                                    <div class="col-sm-4">
                                        <form:textarea path="remarks" htmlEscape="false" rows="3" maxlength="200" class="form-control"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存">&nbsp;
                                        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="loadDiv('mainCenterDiv','${ctx}/operation/operationRoom/index')">
                                </div>
                            </div>
                        </form:form>
                    </div>

                </div>
            </section>
        </div>
    </div>